/**
 * 
 */
package com.xpec.c4.db.util;

import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

import com.xpec.c4.game.utility.GUIDFactory;

/**
 * GMToolDB相关的工具类。
 * 
 * @author Francois
 */
public class LogDBUtils {

	private static AtomicInteger count = new AtomicInteger();

	private static int seed = 0;
	
	/**
	 * 局號長度
	 */
	private static int ROUND_NUMBER_SIZE = 8;

	/**
	 * 随机获取一个Long值，采用的方法是系统时间和一个随机数的组合。保证基本上全局唯一。
	 * 
	 * @return 生成的随机值
	 */
	static Random random = new Random();

	static RandomUtil randomUtil = new RandomUtil();

	public static long getRandomLong() {
		return GUIDFactory.getLogId();
	}
	
	public static String getRandomString(){ 
		return randomUtil.nextString(ROUND_NUMBER_SIZE);
	}

	/**
	 * id的流水号，经过讨论取2位值，超过就归一，重新算
	 * 
	 * @return author: zhongzhengkai date: 2012 2012-8-15 上午11:12:45
	 */
	private static synchronized int getCount() {
		if (seed < 99) {
			return seed++;
		} else {
			return seed = 0;
		}
	}
}
